package com.api.main.mvc.service.impl;

import com.api.main.mvc.service.DemoService;
import org.springframework.stereotype.Service;

import java.util.Calendar;
import java.util.Date;

/**
 * @auther zhangwj
 * @date 2020/4/26 3:38 下午
 */
@Service(value = "demoService")
public class DemoServiceImpl implements DemoService {
    @Override
    public void demo() {

    }

    public static void main(String[] args) {
        Date date = new Date(1677660671000L);
        System.out.println(getWeekId(date));
    }

    private static Integer getWeekId(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        int year = calendar.get(Calendar.YEAR);
        int weeks = calendar.get(Calendar.WEEK_OF_YEAR);
        return year * 100 + weeks;
    }
}
